<template>
  <div class="address-list">
    <van-address-edit
    :area-list="areaList"
    show-postal
    show-delete
    show-set-default
    show-search-result
    :search-result="searchResult"
    :area-columns-placeholder="['请选择', '请选择', '请选择']"
    @save="onSave"
    @delete="onDelete"
    @change-detail="onChangeDetail"
    />
  </div>
</template>

<script>
import { Toast } from 'vant'
import areaData from '@/assets/area/areaData'
import { getAll } from '@/store/modules/address'
export default {
  name: 'AddressList',
  data() {
    return {
      areaList: areaData,
      searchResult: []
    }
  },
  methods: {
    onSave(e) {
      const data = {}

      data.name = e.name
      data.tel = e.tel
      data.address = e.province + e.city + e.county + e.addressDetail
      data.addressDetail = e.addressDetail
      data.areaCodeL = e.areaCode
      data.postalCode = e.postalCode
      data.isDefault = e.isDefault
      console.log(data)

    //   localStorage.setItem('list', JSON.stringify(data))
    },
    onDelete() {
      Toast('delete')
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: '黄龙万科中心',
            address: '杭州市西湖区'
          }
        ]
      } else {
        this.searchResult = []
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
